/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package uimigration.Plateform.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.BasicEList;
import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

import uimigration.Plateform.Device;
import uimigration.Plateform.PlateformPackage;
import uimigration.Plateform.UserInteractions;
import uimigration.WidgetsModel.APIModel;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Device</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link uimigration.Plateform.impl.DeviceImpl#getIdDevice <em>Id Device</em>}</li>
 *   <li>{@link uimigration.Plateform.impl.DeviceImpl#getName <em>Name</em>}</li>
 *   <li>{@link uimigration.Plateform.impl.DeviceImpl#getHasList <em>Has</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DeviceImpl extends EObjectImpl implements Device {
	/**
	 * The default value of the '{@link #getIdDevice() <em>Id Device</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIdDevice()
	 * @generated
	 * @ordered
	 */
	protected static final int ID_DEVICE_EDEFAULT = 0;

	/**
	 * The cached value of the '{@link #getIdDevice() <em>Id Device</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getIdDevice()
	 * @generated
	 * @ordered
	 */
	protected int idDevice = ID_DEVICE_EDEFAULT;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getHas() <em>Has</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHas()
	 * @generated NOT
	 * @ordered
	 */
	protected EList<UserInteractions> has;

	/**
	 * The empty value for the '{@link #getHas() <em>Has</em>}' array accessor.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getHas()
	 * @generated
	 * @ordered
	 */
	protected static final UserInteractions[] HAS_EEMPTY_ARRAY = new UserInteractions[0];

	/**
	 * The cached value of the '{@link #getUseAPI() <em>Use API</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getUseAPI()
	 * @generated NOT
	 * @ordered
	 */
	protected EList<APIModel> useAPI;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected DeviceImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return PlateformPackage.Literals.DEVICE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getIdDevice() {
		return idDevice;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setIdDevice(int newIdDevice) {
		int oldIdDevice = idDevice;
		idDevice = newIdDevice;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					PlateformPackage.DEVICE__ID_DEVICE, oldIdDevice, idDevice));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET,
					PlateformPackage.DEVICE__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public EList<UserInteractions> getHas() {
		if (has == null) {
			has = new EObjectContainmentEList<UserInteractions>(
					UserInteractions.class, this, PlateformPackage.DEVICE__HAS);
		}
		return has;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public UserInteractions getHas(int index) {
		return (UserInteractions) getHasList().get(index);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public int getHasLength() {
		return has == null ? 0 : has.size();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setHas(UserInteractions[] newHas) {
		((BasicEList<UserInteractions>) getHasList()).setData(newHas.length, newHas);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setHas(int index, UserInteractions element) {
		getHasList().set(index, element);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<UserInteractions> getHasList() {
		if (has == null) {
			has = new EObjectContainmentEList<UserInteractions>(UserInteractions.class, this,
					PlateformPackage.DEVICE__HAS);
		}
		return has;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case PlateformPackage.DEVICE__HAS:
			return ((InternalEList<?>) getHas()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case PlateformPackage.DEVICE__ID_DEVICE:
			return new Integer(getIdDevice());
		case PlateformPackage.DEVICE__NAME:
			return getName();
		case PlateformPackage.DEVICE__HAS:
			return getHasList();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	@SuppressWarnings("unchecked")
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case PlateformPackage.DEVICE__ID_DEVICE:
			setIdDevice(((Integer) newValue).intValue());
			return;
		case PlateformPackage.DEVICE__NAME:
			setName((String) newValue);
			return;
		case PlateformPackage.DEVICE__HAS:
			getHas().clear();
			getHas().addAll((Collection<UserInteractions>) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
		case PlateformPackage.DEVICE__ID_DEVICE:
			setIdDevice(ID_DEVICE_EDEFAULT);
			return;
		case PlateformPackage.DEVICE__NAME:
			setName(NAME_EDEFAULT);
			return;
		case PlateformPackage.DEVICE__HAS:
			getHasList().clear();
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case PlateformPackage.DEVICE__ID_DEVICE:
			return idDevice != ID_DEVICE_EDEFAULT;
		case PlateformPackage.DEVICE__NAME:
			return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT
					.equals(name);
		case PlateformPackage.DEVICE__HAS:
			return has != null && !has.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy())
			return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (idDevice: ");
		result.append(idDevice);
		result.append(", name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

	public EList<APIModel> getUseAPI() {
		// TODO Auto-generated method stub
		return null;
	}

} //DeviceImpl
